package leetcode.code198;

public class Solution4 {

	public static void main(String[] args) {
		int[] nums = { 1, 3, 1 };
		int[] nums1 = { 2, 7, 9, 3, 1 };
		int[] nums2 = { 2, 1, 4, 5, 3, 1, 1, 3 };
		Solution4 solution = new Solution4();
		int result = solution.massage(nums2);
		System.out.println(result);
	}

	public int massage(int[] nums) {
		int len = nums.length;
		if (len == 0)
			return 0;
		if (len == 1)
			return nums[0];
		if (len == 2)
			return Math.max(nums[0], nums[1]);
		int num1 = 0;
		int num2 = 0;
		int num3 = 0;
		num1 = nums[0];
		num2 = Math.max(nums[0], nums[1]);
		for (int i = 2; i < nums.length; i++) {
			num3 = Math.max(num2, num1 + nums[i]);
			num1 = num2;
			num2 = num3;
		}
		return num2;
	}

}
